unordered_map<Node*, Node*> mapNode;
class Solution {
public:
    Node* copyRandomList(Node* head) {
        if (head == nullptr)
        {
            return nullptr;
        }
        while (!mapNode.count(head))
        {
            Node* newhead = new Node(head->val);
            mapNode[head] = newhead;
            newhead->next = copyRandomList(head->next);
            newhead->random = copyRandomList(head->random);
        }
        return mapNode[head];
    }
};